<template>
  <view class="content-body">
    <view class="cu-bar bg-white margin-top-xs">
      <!--      <view class="action sub-title">-->
      <!--        <text class="text-xl text-bold text-shadow text-custom">商户列表</text>-->
      <!--        <text class="text-ABC text-custom">SHOP</text>-->
      <!--      </view>-->
      <!--      <view class="action" >-->
      <!--        <text class="text-lg text-yellow text-shadow" @tap="addShop">添加</text>-->
      <!--      </view>-->
      <view class="search-form">
        <text class="cuIcon-search"></text>
        <input type="text" v-model="searchTxt" placeholder="输入商户名称"
               confirm-type="search"/>
      </view>
      <view class="action">
        <button class="cu-btn text-white text-custom-bg"
                @tap.stop="searchMsgList">搜索</button>
      </view>
    </view>
    <scroll-view scroll-y class="indexes">
      <view class="cu-list menu sm-border bg-gray">
        <shop-one-list2 v-for="(item,idx) in allShops" :shop="item"></shop-one-list2>
        <view class="text-gray text-center" style="padding: 10px 0px">~~我是有底线的~~</view>
      </view>
    </scroll-view>
  </view>
<!--  <view class="cu-list menu-avatar bg-gray">-->

<!--  </view>-->
</template>

<script setup lang="ts">
import {ref, onMounted, computed, reactive} from 'vue';
import {getOfflineAllShopList} from '../../common/api/shop'
import {useStore} from "../../common/store";
import ShopOneList from "../../components/ShopOneList.vue";
import ShopOneList2 from "../../components/ShopOneList2.vue";
const store = useStore();
const userId = computed(() => store.userId)
const city = computed(() => store.city)
const list = reactive([])

const searchTxt = ref('')

const tabIndex = ref(0)
const tabs = reactive([
  {name: '全部商户', ind: 0},
  {name: '我的商户', ind: 1},
  {name: '团队商户', ind: 2}
])
const allShops = ref([]);
const myShops = ref([]);
const groupShops = ref([]);

const tabSelect = (index) => {
  tabIndex.value = index;
}

const gotoShopInfo = (id) => {
  uni.navigateTo({url: `/pages/shop/shopInfo?id=${id}`})
}

const initShopList = async () => {
  await getOfflineAllShopList({
    search: searchTxt.value,
    city: city.value || '南通'
  }).then(res => {
    if (res.code == 200) {
      allShops.value = res.data;
    }
  })
}
const searchMsgList = async () => {
  await initShopList();
}

onMounted(async () => {
  await initShopList();
})
</script>

<style  lang="scss" scoped>
 .shop-title{
   font-weight: bold;
   font-size: 36rpx;
   color: #1A1A1A;
 }
 .text-cur{
   font-weight: bold;
   font-size: 32rpx;
   color: #1A1A1A;
   border-bottom: 1rpx solid #1A1A1A;
 }
 .content-body{
   background-color: #f0f0f0;
   color: #333333;
   height: 100vh;
 }

 .indexes {
   height: 90vh;
   //margin-top:120rpx;
 }
</style>
